module.exports = (role) => {
    return async (ctx, next) => {
        if (ctx.session.user) {
            if (role) {
                if (role.includes(ctx.session.user.role)) {
                    await next()
                } else {
                    ctx.throw(403, '权限错误')
                }
            } else {
                await next()
            }
        } else {
            ctx.throw(401, '您没有登录或登录超时')
        }
    }
}
